/* 对用户列表进行增删改查的操作 */
// 链接数据库
const db = uniCloud.database();
// 获取 `user` 集合的引用
const collection = db.collection('User_Information');

// 获取用户信息列表
const getUserList = async (data) => {
	try {
		const res = await collection.get()
		return res
	} catch (e) {
		//TODO handle the exception
	}
}
// 查找登陆人
const findUser = async (data) => {
	try {
		const res = await collection.where(data).get()
		return res
	} catch (e) {
		//TODO handle the exception
	}
}


/* 
 * event为客户端上传的参数
 */
exports.main = async (event, context) => {
	console.log('event', event);
	const {action,params} = event || {}
	switch (action) {
		case 'getUserList':
			return await getUserList(params);
			break;
		case 'findUser':
			return await findUser(params);
			break;
		default:
			return await getUserList(params);
			break;
	}
};
